﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demo3
{
    internal class Program
    {
        /// <summary>
        /// 逻辑运算符
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var boolA = true;
            var boolB = false;
            var boolC = true;
            var boolD = false;

            Console.WriteLine("行1：boolA&&boolB，结果为{0}", boolA && boolB);
            Console.WriteLine("行2：boolA&&boolC，结果为{0}", boolA && boolC);
            Console.WriteLine("行3：boolA||boolB，结果为{0}", boolA || boolB);
            Console.WriteLine("行4：boolA||boolC，结果为{0}", boolA || boolC);
            Console.WriteLine("行5：boolB||boolD，结果为{0}", boolB || boolD);

            // 判定是否为闰年
            var year = 2024;
            //如何判定year是否为闰年？
            //1.年份能被4整除但不能被100整除 或 2.年份能被400整除
            // 关系运算和逻辑运算表示
            if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
            {
                Console.Write("{0}是闰年", year);
            }
            else
            {
                Console.Write("{0}不是闰年", year);
            }

            Console.ReadKey();
        }
    }
}
